package Demo4;

import java.util.Arrays;
import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 洪汤泽大帅哥
 * Date: 2024-12-22
 * Time: 10:56
 */
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        StringBuilder[] strings = new StringBuilder[n];
        StringBuilder[] ret = new StringBuilder[n];
        for (int i = 0; i < n; i++) {
            strings[i] = new StringBuilder(sc.next());
            ret[i] = new StringBuilder(strings[i].substring(6,14));
        }
        Arrays.sort(ret,0,n);
        for (int i = 0; i < n; i++) {
            ret[i].insert(4,'-');
            ret[i].insert(7,'-');
            System.out.println(ret[i]);
        }
    }
}
